import request from '@/utils/request'

export function register(user) {
  return request({
    url: '/api/User/register',
    method: 'post',
    data: user
  })
}

export function login(data) {
  return request({
    url: '/api/User/login',
    method: 'post',
    data
  })
}

// 修改用户
export function edit(id, data) {
  return request({
    url: '/api/User/' + id,
    method: 'patch',
    data: data
  })
}

export function getInfo(id) {
  return request({
    url: '/api/user/' + id,
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/vue-admin-template/user/logout',
    method: 'post'
  })
}

export function getList(search) {
  return request({
    url: '/api/user',
    method: 'get',
    params: search
  })
}

// 设置头像
export function setPhoto(id, imgpath) {
  return request({
    url: '/api/User/setImg/' + id,
    method: 'patch',
    params: { imgpath: imgpath }
  })
}

// 根据用户id获取擅长的设计工具id数组
export function getToolsById(id) {
  return request({
    url: '/api/User/' + id + '/designTools',
    method: 'get'
  })
}

// 根据用户id获取擅长的产品id数组
export function getProductsById(id) {
  return request({
    url: '/api/User/' + id + '/Begoodat',
    method: 'get'
  })
}

// 设置用户的擅长的产品
export function setProducts(id, pids) {
  return request({
    url: '/api/User/' + id + '/begoodat',
    method: 'post',
    data: pids
  })
}

